#if($msg)
<script>
alert('$!msg');
</script>
#end
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>编辑文件</title>
<link href="/include/manage/images/main/style.css" rel="stylesheet" type="text/css" />
<link href="/include/manage/dialog/asyncbox.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/include/manage/js/jquery.js"></script>
<script type="text/javascript" src="/include/manage/js/AsyncBox.js"></script>
<script type="text/javascript" src="/include/manage/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/include/manage/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="/include/manage/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="/include/manage/swfupload/zip_handlers.js"></script>
<script language="javascript">
jQuery.ajaxSetup ({
	cache: false
});

var swfu;
var uploadNum=0;

jQuery(function(){
	$('#unzip').click(function(){
		asyncbox.open({
			title : '解压文件',
			url : '/include/manage/unzip.jsp?id=$!custom.id',
			width : 400,
			height : 300,
			modal : true,
			tipsbar:{
				title : '解压上传的文件',
				content : '解压并发布上传的文件，文件将解压到“/upload/others/命名规则/文件名/”下'
				},
			btnsbar : jQuery.btn.OK,
			callback : function(action,iframe){
			}
		});
	});
	
	//初始化上传组件
			var settings = {
				flash_url : "/include/manage/swfupload/swfupload.swf",
				upload_url: "/ZipUpload?sid=$!sid",
				file_size_limit : "1024 MB",
				file_types : "*.zip",
				file_types_description : "压缩文件",
				file_upload_limit : 1,
				file_queue_limit : 0,
				custom_settings : {
					progressTarget : "fsUploadProgress",
					cancelButtonId : "btnCancel"
				},
				debug: false,
				// Button settings
				button_width: "52",
				button_height: "20",
				button_placeholder_id: "spanButtonPlaceHolder",
				button_text: "添加文件",
				
				moving_average_history_size: 40,
				
				// The event handler functions are defined in handlers.js
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete	// Queue plugin event
			};

			swfu = new SWFUpload(settings);
});

function uploadDocument(){
	/*
	#if($custom.file.length()>0)
	*/
	asyncbox.confirm('注意：之前已上传了文件，您确定要删除已上传的文件吗？','删除资料',function(action){
	　　　if(action == 'ok'){
			jQuery.get("/manage_custom_ajax.ad" , { parameter : "remove", id : "$!custom.id" }, function(data){
				//zTree1.addNodes(zTree1.getSelectedNode(), [{ id:data,name:newtypename}]);
				jQuery("#url").val('');
				//这里不应该清除下述字段，否则就干扰了新的上传
				//$("#doctype").val('');
				//$("#documentfile").val('');
				asyncbox.open({
					title : "预览附件",
					html : "<div id='showStatus'><div class='fieldset flash' id='fsUploadProgress'><span class='legend'></span></div><div id='divStatus'>已上传0个文件</div></div>",
					width : 500,
					height : 300
			　	});
				swfu.startUpload();
			});
	　　　}
	});
	/*
	#else
	*/
	asyncbox.open({
		title : "预览附件",
		html : "<div id='showStatus'><div class='fieldset flash' id='fsUploadProgress'><span class='legend'></span></div><div id='divStatus'>已上传0个文件</div></div>",
		width : 500,
		height : 300
	});
	swfu.startUpload();
	/*
	#end
	*/
}

function checkForm(){
	var isok=true;
	if(jQuery("#name").val().length==0){
		alert("名称不能为空！");
		jQuery("#name")[0].focus();
		isok = false;
	}
	if(isok==true){
		if(uploadNum>0){
			uploadDocument();
		}else{
			$("#writeform").submit();
		}
	}
}
</script>
</head>
<body>
<form id="writeform" name="writeform" method="post" action="/manage_custom.ad">
	<input type="hidden" name="parameter" value="$!action" />
	<input type="hidden" name="id" value="$!custom.id" />
    <input type="hidden" name="site" value="$!sid" />
    <input type="hidden" name="status"#if($custom.status) value="$!custom.status"#else value="0"#end />
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td height="30" background="/include/manage/images/main/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="12" height="30"><img src="/include/manage/images/main/tab_03.gif" width="12" height="30" /></td>
						<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td width="46%" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td width="5%"><div align="center"><img src="/include/manage/images/main/tb.gif" width="16" height="16" /></div></td>
												<td width="95%"><span class="STYLE3">当前位置</span>：[内容管理]-[任意文件]</td>
											</tr>
										</table></td>
									<td width="54%"></td>
								</tr>
							</table></td>
						<td width="16"><img src="/include/manage/images/main/tab_07.gif" width="16" height="30" /></td>
					</tr>
				</table></td>
            </tr>
            <tr>
			<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="8" background="/include/manage/images/main/tab_12.gif">&nbsp;</td>
						<td>
                        	<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#b5d6e6">
								<tr>
									<td width="20%" height="25" bgcolor="#ffffff">&nbsp;文件名称：</td>
									<td width="50%" bgcolor="#ffffff">&nbsp;<input id="name" type="text" name="name" value="$!custom.name" />
									</td>
									<td bgcolor="#ffffff">&nbsp;</td>
								</tr>
                                <tr>
									<td width="20%" height="25" bgcolor="#ffffff">&nbsp;所属站点：</td>
									<td width="50%" bgcolor="#ffffff">&nbsp;#if($custom.getSiteName())$!custom.getSiteName()#else$!sid#end
									</td>
									<td bgcolor="#ffffff"></td>
								</tr>
                                <tr>
									<td width="20%" height="25" bgcolor="#ffffff">&nbsp;上传日期：</td>
									<td width="50%" bgcolor="#ffffff">&nbsp;<input type="hidden" name="date" value="$!custom.date" />$!custom.date
									</td>
									<td bgcolor="#ffffff"></td>
								</tr>
                                <tr>
									<td width="20%" height="25" bgcolor="#ffffff">&nbsp;文件地址：</td>
									<td width="50%" bgcolor="#ffffff">&nbsp;
                                        <input type="text" name="url" id="url" value="$!custom.url" />
                                        <div style="width:50px;height:22px;float:left;border:1px solid gray;margin-left:4px"><span id="spanButtonPlaceHolder"></span>
                                        </div>
                                        #if($custom.url)
                                    	<a href="$!custom.url">查看</a>
                                        #end
									</td>
									<td bgcolor="#ffffff">文件必须是zip格式，上传审批通过后可自动解压</td>
								</tr>
                                <tr>
									<td width="20%" height="25" bgcolor="#ffffff">&nbsp;文件大小：</td>
									<td width="50%" bgcolor="#ffffff">&nbsp;$!custom.size
									</td>
									<td bgcolor="#ffffff"></td>
								</tr>
								#if($custom.status==1)
								<tr>
									<td width="20%" height="25" bgcolor="#ffffff">&nbsp;文件列表：</td>
									<td width="50%" bgcolor="#ffffff">
										#foreach($afile in $custom.getFiles())
										&nbsp;<a href="$!afile.url" target="_blank">$!afile.name</a><br/>
										#end
									</td>
									<td bgcolor="#ffffff"></td>
								</tr>
								#end
                                <tr>
									<td width="20%" height="25" bgcolor="#ffffff">&nbsp;文件说明：</td>
									<td colspan="2" bgcolor="#ffffff">
                                    	<textarea cols="60" name="description">$!custom.description</textarea>
									</td>
								</tr>
                      	</table>
                      </td>
						<td width="8" background="/include/manage/images/main/tab_15.gif">&nbsp;</td>
					</tr>
				</table></td>
		</tr>
		<tr>
			<td height="35" background="/include/manage/images/main/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td width="12" height="35"><img src="/include/manage/images/main/tab_18.gif" width="12" height="35" /></td>
						<td valign="top"><div align="center">
								<input type="button" name="Save" value="保存" onClick="checkForm()" />
								&nbsp; &nbsp;
								<input type="reset" name="Reset" value="重写" />
                                &nbsp; &nbsp;
                                #if($action=="update")
                                    #if($pop>0)
                                    <input id="unzip" type="button" name="unzip" value="审核并解压" />
                                    #end
                                #end
							</div></td>
						<td width="16"><img src="/include/manage/images/main/tab_20.gif" width="16" height="35" /></td>
					</tr>
				</table></td>
		</tr>
	</table>
</form>
</body>
</html>